<?php
session_start();
require '../config.php';
error_reporting(5);
error_reporting(E_ALL & ~E_NOTICE);
error_reporting(0);

$email=$_POST['uemail'];
$pword=$_POST['pword1'];
$name=$_POST['uname'];
$phone=$_POST['uphone'];
$address=$_POST['uaddress'];
$pub_time=Date('Y-m-d H:i:s');
// 将form表单中的email、username、pword、pword2进行赋值
$query="SELECT * FROM users WHERE `uemail`='$email'";
     $result = mysqli_query($config,$query);
     if ($result) {
     	$row=mysqli_fetch_array($result,MYSQLI_ASSOC);
     	if ($row) {
     		echo ('<script type="text/javascript">alert("邮箱已被注册！请从新注册");
     			window.history.back(-1);
     			</script>');

     	}
        else{





$pword=md5($pword);
// 将注册的密码进行md5加密并插入进入users数据表中

$query="INSERT INTO users(`uemail`,`upassword`,`uname`,`uphone`,`pub_time`,`uaddress`) VALUES('$email','$pword','$name','$phone','$pub_time','$address')";
$result = mysqli_query($config,$query)or die("error:".mysqli_error());
echo $query;
if ($result) {
	echo ('<script type="text/javascript">alert("注册成功");
		window.location.href = "index.php";
		</script>');
}else{
	echo('<script type="text/javascript">alert("注册失败");
		</script>');
}
}


     }
     ?>
